package com.hrm.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hrm.entity.Person;


public class PersonDaoImpl implements PersonDao{
	static Map<Long,Person> persons=new HashMap<Long, Person>();
	static{
		persons.put(Long.parseLong("1"), new Person(Long.parseLong("1"),"John","White"));
	}

	public Person getPerson(Long personId) {
		return persons.get(personId);
	}

	public void savePerson(Person person) {
		persons.put(person.getId(), person);
		System.out.println(persons.get(person.getId()).getFirstName());
	}

	public List<Person> getPeople() {
		List<Person> pList=new ArrayList<Person>();
		for(Long o:persons.keySet()){
			pList.add(persons.get(o));
		}
		return pList;
	}

	public void deletePerson(Long personId) {
		persons.remove(personId);
	}

	public void updatePerson(Person person) {
		persons.remove(person.getId());
		this.savePerson(person);
	}

}
